<template>
  <div class="iu-card">
    <div class="iu-card-icon" v-if="icon">
      <slot name="icon"></slot>
    </div>
    <div class="iu-card-wrapper">
      <div class="iu-card-header" :class="{'iu-card-header-full':full}">
        <div class="iu-card-title" :class="{'ellipsis':ellipsis}">
          <slot name="title"></slot>
        </div>
        <div class="iu-card-title-tip" :class="tipType">
          <slot name="tip"></slot>
        </div>
      </div>
      <div class="iu-card-body" :class="{'ellipsis':ellipsis}">
        <slot name="body"></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "card",
  props: {
    icon: {
      type: Boolean,
      default: false,
    },
    ellipsis: {
      type: Boolean,
      default: false,
    },
    full: {
      type: Boolean,
      default: false,
    },
    tipType: {
      type: String,
      default: '',
    },
  },
};
</script>
<style lang="less" scope>
.iu-card {
  padding: 0;
  background: #292a4d;
  border-radius: 4px;
  transition: 0.3s all ease-in-out;
  display: flex;
  line-height: 1.3;
  &.iu-card-active {
    background: #383a69;
  }
  .iu-card-icon {
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    img {
      width: 30px;
      height: auto;
    }
  }
  .iu-card-wrapper {
    flex: 1;
    padding: 8px 0;
    overflow: hidden;
  }
  .iu-card-header {
    color: #fff;
    font-size: 16px;
    padding: 0 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .iu-card-header-full {
    .iu-card-title {
      width: 100% !important;
    }
    .iu-card-title-tip {
      display: none !important;
    }
  }
  .iu-card-title {
    width: 70%;
    &.ellipsis {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
  .iu-card-title-tip {
    font-size: 14px;
    width: 30%;
    text-align: right;
    line-height: 1;
    &.error {
      color: #ff2c2c;
    }
    &.info {
      color: rgba(255, 255, 255, 0.6);
    }
    &.success {
      color: #4fdbe5;
    }
    &.warning {
      color: #dd9710;
    }
    &.primary {
      color: #456de6;
    }
  }
  .iu-card-body {
    font-size: 14px;
    padding: 4px 8px 0 8px;
    // color: rgba(255, 255, 255, 0.6);
    color: #fff;
    word-break: break-all;

    &.ellipsis {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
}
</style>
